package com.example.utils;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by User on 2015/6/30.
 */
public class DBUtils extends SQLiteOpenHelper{

    public DBUtils(Context context) {
        super(context, "cart.db", null,3);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {

        //创建表
        db.execSQL("create table t_cart(_id integer primary key,id,title vrachar,title2 vrachar,img varchar,price,number)");


    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {


        //数据库版本升级或发生变化，需要删除表结构并重创建
        if(newVersion>oldVersion) {
            db.execSQL("drop table if exists t_cart");

            onCreate(db);

        }



    }
}
